package com.yb.xczx.security.resource.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/5/22 13:01
 * FileName: XczxSecurityBeanDefinitionRegistryPostProcessor
 * Description:
 */

@Slf4j
public class XczxSecurityBeanDefinitionRegistryPostProcessor implements ImportBeanDefinitionRegistrar {
    BeanDefinitionRegistryPostProcessor a= null;
    public  void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

//        if (!importingClassMetadata.hasAnnotation(EnableXcxzOauth2ResourceSecurity.class.getName())) {
//            return;
//        }
//
//        AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(EnableXcxzOauth2ResourceSecurity.class.getName()));
//        boolean jwtEnable = annotationAttributes.getBoolean("jwtEnable");
//        if(jwtEnable){
//            BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(OAuth2JwtTokenConfiguration.class);
//            registry.registerBeanDefinition("oAuth2JwtTokenConfiguration",beanDefinitionBuilder.getBeanDefinition());
//            log.info("register oAuth2JwtTokenConfiguration");
//        }else{
//            BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(Oauth2OpaqueTokenConfig.class);
//            registry.registerBeanDefinition("oauth2OpaqueTokenConfig",beanDefinitionBuilder.getBeanDefinition());
//            log.info("register oauth2OpaqueTokenConfig");
//        }
    }


}
